

#region Using Statements
using System;
using System.Collections.Generic;//using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;
#endregion



namespace Pauliver
{
    public class DynamicLevel : Level
    {
        public DynamicLevel(Texture2D Left,Texture2D Right, Texture2D p_MiniMap,BaseCollision p_Collision,TerrainSaver ts)
            : base(p_Collision)
        {
            base._terrain = new Terrain(Left,Right, p_MiniMap, ts);
        }

        public override void Draw(SpriteBatch p_SpriteBatch, GameTime p_GameTime, Rectangle p_Screen)
        {
            Vector2 LeftUpperLeft = Vector2.Zero - new Vector2(120, 0) - new Vector2(p_Screen.X, p_Screen.Y);
            Vector2 RightUpperLeft = LeftUpperLeft + new Vector2(_terrain.BackgroundLeft.Width, 0);

            p_SpriteBatch.Draw(_terrain.BackgroundLeft, LeftUpperLeft, null, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.99f);
            p_SpriteBatch.Draw(_terrain.BackgroundRight, RightUpperLeft, null, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0.99f);

            Texture2D blackbox = PContentManager.Instance.GetObject<Texture2D>(@"Content/Art/MiniMap/TerrainPiece");
            int start = p_Screen.Left;
            int end = p_Screen.Right;
            for (int i = start; i < end; ++i)
            {
                p_SpriteBatch.Draw(blackbox, new Vector2(i - p_Screen.Left, this[i] - p_Screen.Top), null, Color.White, 0.0f, Vector2.Zero, new Vector2(1.0f, 1.0f), SpriteEffects.None, 0.97f);
            }
        }

        public int this[int x]
        {
            get
            {
                return base._terrain[x];
            }
        }
    }
}